package com.itheima.user.controller;


import com.itheima.feign.client.MovieClient;
import com.itheima.feign.domain.Movie;
import com.itheima.user.common.ResultInfo;
import com.itheima.user.domain.User;
import com.itheima.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;
    @Autowired
    private MovieClient movieClient;

    //1.登录成功后返回token给前端
    @PostMapping("/login")
    public String login (@RequestBody User user){
       String token= userService.login(user.getUsername(),user.getPassword());
       return token;
    }

    //2.查询电影列表
    @GetMapping("/movie")
    public List<Movie> list(){
        List<Movie> list = movieClient.list();
        return list;
    }

}
